//
//  CreateJobReviewDetailView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/3/7.
//

import UIKit
import SnapKit
import Rswift
class CreateJobReviewDetailView: CreateJobBaseView {
    let topView = CreateJobReviewTopView()
    let summaryView = CreateJobReviewSummaryView()
    let installAddressView = CreateJobReviewInstallAddressView()
    let siteAttributeView = CreateJobReviewSiteAttributesView()
    let ownerInfoView = CreateJobReviewOwnerInfoView()
    let installDateView = CreateJobReviewInstallDateView()
    let systemDetailView = CreateJobReviewSystemDetailView()
    let technicianDetailsView = CreateJobReviewInstallerDetailView()

    override func setUpContentView() {
        self.continueBtn.setTitle(R.string.localizable.createJob(), for: UIControl.State.normal)
        //
        self.contentView.addSubview(topView)
        topView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.left.right.equalToSuperview()
            make.height.greaterThanOrEqualTo(0)
        }
        //summary view
        self.contentView.addSubview(summaryView)
        summaryView.snp.makeConstraints { make in
            make.top.equalTo(topView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //installAddressView
        self.contentView.addSubview(installAddressView)
        installAddressView.snp.makeConstraints { make in
            make.top.equalTo(summaryView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //site attributes
        self.contentView.addSubview(siteAttributeView)
        siteAttributeView.snp.makeConstraints { make in
            make.top.equalTo(installAddressView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //Job details
        self.contentView.addSubview(ownerInfoView)
        ownerInfoView.snp.makeConstraints { make in
            make.top.equalTo(siteAttributeView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //schedule date of install
        self.contentView.addSubview(installDateView)
        installDateView.snp.makeConstraints { make in
            make.top.equalTo(ownerInfoView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //systemDetailView
        self.contentView.addSubview(systemDetailView)
        systemDetailView.snp.makeConstraints { make in
            make.top.equalTo(installDateView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
        }
        //technicianDetailsView
        self.contentView.addSubview(technicianDetailsView)
        technicianDetailsView.snp.makeConstraints { make in
            make.top.equalTo(systemDetailView.snp.bottom)
            make.left.right.equalTo(topView)
            make.height.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-20)
        }
    }
    func setData(){
        self.summaryView.setData()
        self.installAddressView.setData()
        self.siteAttributeView.setData()
        self.ownerInfoView.setData()
        self.installDateView.setData()
        self.systemDetailView.setData()
        CreateJobModelHelper.shared.systemInfoObserver.onNext(CreateJobModelHelper.shared.createJobViewModel.systemDetail)
        CreateJobModelHelper.shared.installerDetailObserver.onNext(CreateJobModelHelper.shared.createJobViewModel.installerDetail)
    }
}
let CREATEJOB_REVIEW_INTERNAL: Int = 10
//Review界面字体是统一的title和label
class CreateJobReviewTitleLabel: BaseLabel {
    init(_ text: String = "") {
        super.init(frame: CGRect.zero)
        self.initView(R.font.interMedium(size: 13)!, content: text, hexStr: "#292D3280")
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func initView(_ font: UIFont?, content: String = "",hexStr: String) {
        self.setFont(font)
        self.adjustsFontForContentSizeCategory = true
        self.textColor = UIColor(hexStr: hexStr)
        self.text = content
    }
}
class CreateJobReviewContentLabel: BaseLabel {
    init() {
        super.init(frame: CGRect.zero)
        self.initView(R.font.interMedium(size: 13)!,  hexStr: "#292D32")
        
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func initView(_ font: UIFont?,hexStr: String) {
        self.setFont(font)
        self.adjustsFontForContentSizeCategory = true
        self.textColor = UIColor(hexStr: hexStr)
    }
}
